package com.lemon.smartsafetynew.ui.adapter.me;

import android.support.annotation.NonNull;
import android.support.annotation.Nullable;

import com.lemon.smartsafety.ui.adapter.common.RcvViewType;
import com.lemon.smartsafetynew.entity.me.MeRcvItemBase;
import com.lemon.smartsafetynew.ui.adapter.common.SectionEndButtonView;
import com.lemon.smartsafetynew.ui.adapter.common.SectionHeadViewNew;
import com.lemon.smartsafetynew.ui.adapter.work.WorkOptionItemViewRec;

import java.util.List;

import kale.adapter.LemonRcvAdapter;
import kale.adapter.item.AdapterItem;

/**
 * Created by Andrew on 2017/7/4.
 */

public class MeFragmentAdapter extends LemonRcvAdapter<MeRcvItemBase> {

    private List<MeRcvItemBase> mItems;


    public MeFragmentAdapter(@Nullable List<MeRcvItemBase> data) {
        super(data);
        this.mItems = data;
    }

    @Override
    public int getItemCount() {
        return this.mItems.size();
    }

    @Override
    public Object getItemType(MeRcvItemBase meRcvItemBase) {
        return meRcvItemBase.getViewType();
    }

    @NonNull
    @Override
    public AdapterItem createItem(Object type) {
        RcvViewType.MeRcvViewType myType = (RcvViewType.MeRcvViewType) type;

        if (myType == RcvViewType.MeRcvViewType.TYPE_GROUP_1_OPTION) {
            return new MeOptionItemViewRec();
        } else if(myType == RcvViewType.MeRcvViewType.TYPE_GROUP_2_OPTION) {
            return new MeOptionItemViewRec();
        } else if(myType == RcvViewType.MeRcvViewType.TYPE_USER_INFO_CARD) {
            return new MeInfoAdapterItem();
        } else if(myType == RcvViewType.MeRcvViewType.TYPE_USER_LOGOUT){
            return new SectionEndButtonView();
        }
        return new SectionHeadViewNew();
    }
}
